package com.xcl.controller;

import com.xcl.service.DeliveryChargeServiceInter;
import com.xcl.service.FinancingServiceInter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName DeliveryChargeController
 * @Description 应付派送费控制器层
 * @Author: xiaochaolei
 * @date 2021/7/27 11:06
 * @Version 1. 0
 */
@Controller
public class DeliveryChargeController {
    @Autowired
    DeliveryChargeServiceInter deliveryChargeServiceInter;
    @Autowired
    FinancingServiceInter financingServiceInter;

    /**
     * 分页以及多条件查询
     * @param page 页码数
     * @param limit 条目数
     * @param delivery_id 派送单号
     * @param waybill_id 运单号
     * @param deliveryDate 派送日期
     * @param sub_id 所在分站
     * @param ownerName 司机名称
     * @param verification 是否核销
     * @return map集合的派送模型
     */
    @GetMapping(value = "/DeliveryChargeControllerGetAllDeliveryCharge", produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> getAllDeliveryCharge(int page, int limit, String delivery_id,
                                                   String waybill_id,
                                                   String deliveryDate,
                                                   String sub_id,
                                                   String ownerName,
                                                   String verification){
        Map<String,Object> map=new HashMap<>();
        map.put("code","0");
        map.put("msg","0");
        map.put("count",deliveryChargeServiceInter.getAllDeliveryCharge().size());
        map.put("data",deliveryChargeServiceInter.getAllDeliveryChargeByLimit(page,limit,delivery_id,
                waybill_id,
                deliveryDate,
                sub_id,
                ownerName,
                verification));
        return map;
    }



    @PostMapping(value = "/DeliveryChargeControllerUpdateVerification", produces = "application/text;charset=utf-8")
    @ResponseBody
    public String updateVerification(String id){
        //修改财务信息
         int financeById = deliveryChargeServiceInter.getFinanceById(id);
        if (deliveryChargeServiceInter.updateVerification(id)>0){
            return "成功";
        }
        return "失败";
    }
}
